home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
scope
/
051-075
/
scopedisk69
/
jlib20a
/
jlib.doc
< prev
next >
Wrap
Text File
|
1995-03-19
|
27KB
|
697 lines
<<< jlib >>>
Version 2.0a of jlib
A set of Enhancements for AmigaBASIC
Copyright © by john everett
PeopleLINK ID JAE
321 Hodges
Memphis, TN 38111
(901)-452-2560
===============================================================================
jlib (and all its associated files) is (are) Copyright (©) 1989 by john
everett and may be freely distributed providing the following conditions are
met:
1. It is not altered in any way
2. All files in the original ARCed file are included with the distribution
or
If distibuted with an application, the about& requester is either called
or access to it is provided through menu selection or similar function.
Although jlib is not a SHAREWARE program, any and all donations will be MOST
GRATEFULLY accepted, and would most likely result in more and continued
support for jlib.
===============================================================================
CHANGES/REVISIONS/BUGFIXES:
-Version 2.0a (Thanks to Charles Massey for reporting it & testing fixes)
Bug in getmem& caused the demo to guru on machines with expanded memory.
This has been fixed. Also cleaned up the font routines some.
===============================================================================
These commands are an alternative to the BMAPs for accessing the library
routines on the Amiga. No need to remember which functions need a DECLARE
FUNCTION statement, as none are needed with jlib. Most do more than just
access the normal library routine, they do the work of some small
subprograms/subroutines. This saves programming time and program space.
Support is included for many graphics and dos routines, font routines,IFF
picture loading and saving (via the iff.library, which was written by
Christian A. Weber, in Zurich, Switzerland, and is Public Domain! Thanks,
Christian!), and the ARP file requester (thanks to Charlie Heath and the
other ARP programmers!). Following you will find instructions for setting
up these routines, and short descriptions of each.
===============================================================================
READ ALL INSTRUCTIONS CAREFULLY BEFORE USING jlib!!! THE USE OF SYSTEM
ROUTINES CAN EASILY CAUSE VISITS FROM THE GURU IF ANY MISTAKES ARE MADE!!!
BE CAREFUL!!!
===============================================================================
The first thing you must do is declare all of the function names as
variables. Next, you DIM an array to hold the loader program, load it in,
and call it. You may ERASE the array afterwards, as it will no longer be
needed.
'========== the jlib variable table - MUST NOT BE ALTERED!!!
jlib&=0
about&=0:w7&=0:bye&=0:getmem&=0:freemem&=0:zip&=0:copy&=0:anycmd&=0'jlib/exec
at&=0:text&=0:printat&=0:shadow&=0:sxy&=0:scolr&=0 'graphics
sbox&=0:dbox&=0:drawmode&=0:rgb&=0:blowup&=0
title&=0:autoreq&=0:refresh&=0:setptr&=0:clrptr&=0:sgad&=0 'intuition
exp1&=0:exp2&=0:exp3&=0:exp4&=0:exp5&=0:exp6&=0:exp7&=0:exp8&=0:exp9&=0
bload&=0:bsave&=0:openDOS&=0:DOSfile&=0:closeDOS&=0 'dos
checkfile&=0:request&=0:DOScmd&=0
loadiff&=0:saveIFF&=0:load8svx&=0:play8svx&=0:kill8svx&=0 'iff/8svx
loadfont&=0:usefont&=0:killfont&=0:style&=0 'font
'========== these are highly recommended - but not required
nl$=CHR$(0):nl3$=STRING$(3,0)
'========== load and set up the jlib file
OPEN "jlib.ldr" FOR INPUT AS #1
mlsize=LOF(1)/2-1:DIM ml(mlsize)
FOR i=0 TO mlsize:ml(i)=CVI(INPUT$(2,1)):NEXT
CLOSE #1
ml&=VARPTR(ml(0)):ml& SADD("jlib2"+nl$),VARPTR(jlib&),WINDOW(7):ERASE ml
This short routine reserves some non-relocatable memory, then loads the main
routine, and tells it to initialize itself and the variables to the proper
addresses. It then returns control to BASIC. This entire process takes at
most, a couple of seconds, very little of your BASIC program space, and
gives you a LOT of power to dress up and speed up your programs.
The best way to start a program using jlib is to start from a copy of
jlib.hdr or a similar start-up file. This saves typing all the variables,
and ensures you won't have a typo in these important set-up routines.
===============================================================================
NOTES ON USING JLIB:
jlib2 IS NOW COMPATIBLE WITH THE AC/BASIC COMPILER!!! However, it is NOT
compatible with the older version of jlib. Everything that was possible
with the older version is still possible, but may require a different
calling syntax. There is much more power available now, so the change
should be worth it!
All variables used for passing values to a jlib routine must be INTEGERs
(either short or long) or an error will result. If the value will contain a
file handle or memory address, it will need to be a LONG INTEGER.
If using a jlib command in a SUB program, you must declare the command as a
SHARED variable. (ex. SHARED shadow&,sxy&,scolr&,bleeb,blurt)
ALL STRINGS PASSED TO A jlib ROUTINE MUST BE NULL TERMINATED. This will not
be mentioned in the command descriptions (I don't want to have to say it
over and over again), so be aware that if you see anything similar to
SADD(msg$), msg$ will need to be NULL terminated (msg$+nl$, or msg$+CHR$(0)).
All of the following commands may be called using the syntax given, or with
the alternate form using the CALL keyword (ex. CALL at&(x,y)). This syntax
MUST be used when calling after the keywords THEN or ELSE, or when used at
the beginning of a line where they might be confused as labels.
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
The folks at AbSoft have informed me that only the `CALL name&(x,y,z)' form
may be used when calling machine language routines. On the other hand I've
been using the other form all along with no problems (other than the bug in
the compiler). WHAT BUG, you say??? There is currently a bug in the
compiler that prevents it from compiling programs that have more than 249
arguments (total) in calls to machine language (like jlib) routines. They
are working on a fix, but it may not be available until the next compiler
release. There IS a workaround solution that will allow programs to
compile. An example program is included in this ARC called `cbug'. The
demo, however, does not make use of this solution and therefore will not
compile.
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
All return values will be returned in the jlib& variable unless otherwise
specified. If this value will be needed at a later time (such as the
address returned when using getmem&), be sure to copy it to another variable
before calling another jlib routine or it will most likely be overwritten!
Examples: memaddress&=jlib&, topaz8&=jlib&, DOShandle&=jlib&
=====================================================================
about&
DESCRIPTION:
Displays jlib info in system requester. I ask that programs written
using jlib have a menu selection (or similar access) that will call
this item. This is not required, however.
INPUT VALUES:
none
RETURN VALUES:
0 for left button pressed
1 for right button pressed
(who cares, though)
anycmd& offset,d0,d1,d2,d3,d4,d5,d6,d7,a0,a1,a2,a3,a4,a5,a6
DESCRIPTION:
Executes any library function. The library base must be placed in a6
(exceptions: 0 to 3 may be used as per below). The routine will place
all values into their prospective registers and execute the routine at
offset+a6. This will enable you to call any library routine not
directly supported by jlib without using a bmap.
INPUT VALUES:
offset=offset into library for desired function
d0-d7=values to be placed in data registers
a0-a6=values to be placed in address registers
If a6 has a value of 0-3 the following library bases will be placed
in a6. Otherwise you will have to open the needed library yourself
(using this command, NOT the basic command) to get the library base
(in which case you must also close the library).
0=exec.library
1=intuition.library
2=graphics.library
3=dos.library
RETURN VALUES:
-1 if failed completely or the value returned in register d0 (from the
routine called) will be returned in jlib&
at& x,y
DESCRIPTION:
Positions the system drawing position at the specified point. If text
is printed following this command, it will be positioned with the
baseline at this point.
INPUT VALUES:
x=the x position
y=the y position
RETURN VALUES:
none
autoreq& SADD(msg$),SADD(yes$),SADD(no$)
DESCRIPTION:
Calls the system AutoRequest() function with the specified text.
INPUT VALUES:
msg$=the text for the body of the requester. This may be up to 17 (if
I remember right) lines of text. The lines of text are run together
with each line terminating in a NULL$ character, and the last line
teminating with three NULL$ characters (this is what nl3$ was
declared for at the top of the program).
EX:msg$="Hello World"+nl$+"Second line!"+nl$+"Something else"+nl3$
If you want a blank lines, you must put at least three spaces there.
The size of the requester is determined by the longest text line.
Experiment!
yes$=text for positive-response gadget
no$=text for negative-response gadget
RETURN VALUES:
1=positive response
0=negative response
bload& SADD(file$),address,size
DESCRIPTION:
Loads a file into the given memory location (address).
INPUT VALUES:
file$=the name of the input file
address=the memory location to load it into
size=the number of bytes you want loaded
RETURN VALUES:
-1=open failed (file probably wasn't found-should have checkfiled :-) !)
otherwise the actual number of bytes read is returned
blowup& sRP,sx,sy,wide,tall,dRP,dx,dy,mag,pwide
DESCRIPTION:
Enlarges a graphic element.
INPUT VALUES:
sRP=source rastport (WINDOW(8) of source window)
sx=x position of source element
sy=y position of source element
wide=width of source element
tall=height of source element
dRP=destination rastport (WINDOW(8) of destination window)
dx=x position of destination element
dy=y position of destination element
mag=magnification factor
pwide=pixel width of magnified pixels (mag-1 or mag-2 are good)
RETURN VALUES:
none
bsave& SADD(file$),address,size
DESCRIPTION:
Saves a given block of memory (address) to disk (or whatever).
INPUT VALUES:
file$=the name of the input file
address=the memory location of your memory block
size=the number of bytes you want saved
RETURN VALUES:
-1=open failed (file probably wasn't found-should have checkfiled :-) !)
otherwise the actual number of bytes written is returned
bye&
DESCRIPTION:
Causes jlib to quit and clean up after itself. Also releases all
memory allocated with 0 option of getmem&.
INPUT VALUES:
none
RETURN VALUES:
none
checkfile& SADD(file$)
DESCRIPTION:
Checks to see if a file or directory exists.
INPUT VALUES:
file$=the name of the file or directory
RETURN VALUES:
-1=directory found
0=not found (or error condition)
otherwise the value will be the length (in bytes) of the file
closeDOS& handle
DESCRIPTION:
Closes a file previously opened with openDOS&.
INPUT VALUES:
handle=a file handle obtained from openDOS&
RETURN VALUES:
none
clrptr&
DESCRIPTION:
Removes the pointer set with setptr& and returns to the system
pointer. Since setptr& only sets a pointer for the current window,
it may not be necessary to call this routine. When you close the
window or exit your program the pointer will be returned to the system
pointer anyway.
INPUT VALUES:
none
RETURN VALUES:
none
copy& from,to,number,flag
DESCRIPTION:
Copies memory from area to another.
INPUT VALUES:
from=the source address
to=the destination address
number=the number of bytes, words, or long words to be copied
flag
4=longword
2=word
1=byte
0=copy until a NULL$ is encountered
RETURN VALUES:
none
dbox& x,y,SADD(msg$)
DESCRIPTION:
Prints text with a two boxes drawn around it. This can be useful for
use as gadgets, or to draw attention to certain text. The text and
the box outline are drawn with the current foreground color, and the
inside of the box uses the current background color (specified with
the COLOR command). Boxes are sized for whatever the current font is
automatically.
INPUT VALUES:
x=the x position
y=the y position
msg$=the text you wish printed
RETURN VALUES:
none
DOScmd& SADD(command$)
DESCRIPTION:
Executes a DOS command. Works from CLI or WORKBENCH.
INPUT VALUES:
command$=the command to be executed
RETURN VALUES:
none
DOSfile& mode,handle,address/distance,size/seekmode
DESCRIPTION:
Performs operation on a previously opened DOS file.
INPUT VALUES:
mode
0=read
1=write
2=seek
handle=a file handle obtained from openDOS&
address=(read or write mode) the address to read data into
distance=(seek mode) distance to move pointer (negative moves backwards)
size=(read or write mode) the number of bytes to read/write
seekmode (seek mode)
-1=OFFSET_BEGINNING (measures distance from start of file)
0=OFFSET_CURRENT (measures distance from current position)
1=OFFSET_END (measures distance from end of file (a negative value))
RETURN VALUES:
read or write mode
-1 if failed or the number of actual bytes written
seek mode
returns position of pointer after execution
(if distance=0 and mode=0 then it would return the current position)
drawmode& mode
DESCRIPTION:
Sets the system drawmode.
INPUT VALUES:
mode
0=JAM1
1=JAM2
2=COMPLEMENT
4=INVERSVIDeo
RETURN VALUES:
none
exp1&, exp2&, exp3&, etc...
DESCRIPTION:
Reserved for future additions to jlib
INPUT VALUES:
none
RETURN VALUES:
none
freemem& address
DESCRIPTION:
De-allocates memory allocated with getmem& and flag=1.
INPUT VALUES:
address=address of the memory block returned when using getmem&.
Do not call freemem& for memory allocated with the 0 option or the
GURU will pay a visit!
RETURN VALUES:
none
getmem& size,type,flag
DESCRIPTION:
Allocates system memory for user use.
INPUT VALUES:
size=number of bytes of requested memory
type=the type of memory requested
MEMF_PUBLIC=1
MEMF_CHIP=2
MEMF_FAST=4,
MEMF_CLEAR=65536
flag
0=let jlib de-allocate when cleaning up with bye& command
1=will de-allocate with freemem&
RETURN VALUES:
0 if unsuccessful
address of memory block if successful
killfont& handle
DESCRIPTION:
Removes a font from the system font list.
INPUT VALUES:
handle=a font handle obtained with loadfont&
RETURN VALUES:
none
kill8svx&
DESCRIPTION:
Not implemented.
INPUT VALUES:
none
RETURN VALUES:
none
load8svx&
DESCRIPTION:
Not implemented.
INPUT VALUES:
none
RETURN VALUES:
none
loadfont& SADD(fontname$),fontsize
DESCRIPTION:
Loads font data into memory and adds it to the system font list where
it can be used.
INPUT VALUES:
fontname$=name of the requested font
fontsize=height of the requested font
RETURN VALUES:
-1 or 0 if failed otherwise the font handle
loadiff& SADD(file$)
DESCRIPTION:
Loads an iff picture into a previously opened window.
INPUT VALUES:
file$=the filename of the iff picture
RETURN VALUES:
-1 if failed or 0 if successful
openDOS& mode,SADD(file$)
DESCRIPTION:
Opens a DOS file.
INPUT VALUES:
mode
1004=read/write
1005=read
1006=write (erases any previous file by same name)
file$=the name of the file to open
RETURN VALUES:
-1 or 0 if failed, otherwise the file handle
play8svx&
DESCRIPTION:
Not implemented.
INPUT VALUES:
none
RETURN VALUES:
none
printat& x,y,SADD(msg$)
DESCRIPTION:
Combines at& and text& to print text at the specified position. This
command adjusts for the font baseline so that the x,y position will
specify the top left corner of the block that will contain the text.
An additional feature is that if a -1 x value is given, the text will
be printed centered in the window's current drawing area (this will
look slightly off-center to the left if the window has a sizing
gadget). -2 will right-justify the text. Text is printed using the
current colors specified with the COLOR command and the current
drawmode specified with drawmode&.
INPUT VALUES:
x=the x position (-1 to center-justify, or -2 to right-justify)
y=the y position
msg$=the text you wish printed
RETURN VALUES:
none
refresh&
DESCRIPTION:
Calls RefreshWindowFrame() to refresh the window frame (makes sense,
doesn't it?). Can be used (among other things) to change the window
frame's color.
EX: POKE WINDOW(7)+98,textcolor
POKE WINDOW(7)+99,bordercolor
refresh&
If you want to get rid of the window border, just change its color to
the current background color, call refresh&, and it will disappear!
INPUT VALUES:
none
RETURN VALUES:
none
request& x,y,SADD(greet$),SADD(buffer$),flag
DESCRIPTION:
Calls the ARP file requester.
INPUT VALUES:
x=the x position of the requester
y=the y position of the requester
greet$=text to be printed in title bar of requester
buffer$=default directory/filename plus enough space to bring it up to
a sufficient length to accomodate any path/filename. ARP docs say
around 360 characters. For instance:
buffer$="SYS:c/monkeywrench"+STRING$(360,0)
flag
0=default color (use for loads)
1=alternate color (use for saves)
RETURN VALUES:
returns the selected path/filename terminated with a NULL character
then garbage up to the length of buffer$. See sgad& for an easy
method of extracting this information to a usable form.
rgb& flag,address,start,number
DESCRIPTION:
Sets colors to given values or returns current values. Data may be
sent/recieved as colortable data or in integer array form. Color
tables have the red, green and blue values for each color compressed
into one WORD (short integer (or two bytes)) size value. Bits 15-12
will be zeros, 11-8 will hold the red value, 7-4 will hold the green
value, and 3-0 will hold the blue value for each given color. The
color arrays seperate the individual red, green and blue values into
seperate WORDs. rgb& 2,VARPTR(colr(0)),1,1 would place the red value
for color 1 into colr(0), the green value into colr(1), and the blue
value into colr(2). These values would be in the range of 0 to 15 and
would need to be divided by 16 to be used in a PALETTE command. They
could be used as-is with the rgb& flag set to 3.
INPUT VALUES:
flag=(bit0=get/put off/on, bit1=table/array off/on)
0=get color table
1=put color table
2=get color array
3=put color array
address=address to read from (or write to)
start=starting color number
number=the number of colors to be read/written
RETURN VALUES:
none for write operation
color values returned starting at address for read operation
saveiff& SADD(file$)
DESCRIPTION:
Saves the contents of a window as an iff picture file.
INPUT VALUES:
file$=the filename to save the iff picture as
RETURN VALUES:
-1 if failed or 0 if successful
sbox& x,y,SADD(msg$)
DESCRIPTION:
Prints shadow text with a box drawn around it. This can be useful for
use as gadgets, or to draw attention to certain text. Text is printed
using the current scolr& colors. The box outline is drawn with the
current foreground color, and the inside of the box uses the current
background color (specified with the COLOR command). Boxes are
automatically sized for the current font.
INPUT VALUES:
x=the x position
y=the y position
msg$=the text you wish printed
RETURN VALUES:
none
scolr& fg,bg
DESCRIPTION:
Sets the colors for the shadow& command.
INPUT VALUES:
fg=the text foreground color
bg=the shadow color
RETURN VALUES:
none
setptr& image,wide,tall,xoffset,yoffset
alternate syntax:
setptr& image,-1
DESCRIPTION:
Changes the mouse pointer in the current window. You will need to
call setptr& for each window you wish the pointer to be active in.
The alternate syntax may be used if you have the `Prefs' program,
which saves pointers with a .p suffix. Just load a .p file into
memory and call setptr& with the alternate syntax. This command will
not automatically load the colors that are stored with a .p file,
however. If you wish to use these colors use: rgb& 1,image+74,17,3
INPUT VALUES:
image=an intuition image structure which must be in non-relocatable
memory (use the getmem& command)
wide=width of pointer (usually (and never exceeding) 16)
tall=height of pointer
xoffset=x offset of pointer hot spot
yoffset=y offset of pointer hot spot
RETURN VALUES:
none
sgad& x,y,wide,tall,length,flag,SADD(buffer$)
DESCRIPTION:
Gets input from a system string (or integer) gadget. No border is
drawn around the gadget. This was done so that you could design a
screen with a painting program, or use dbox& (or whatever), and not
have the gadget ruin your graphics. If a plain border is all thats
wanted, then a simple LINE (x-1,y-1)-STEP(wide+1,tall+1),colr,b) would
draw a border around the gadget. No automatic border seemed to give
more options in the long run.
INPUT VALUES:
x=x position of `hot' area
y=y position of `hot' area
wide=width of `hot' area
tall=height of `hot' area
length=maximum number of characters in string +1 (for the NULL
terminator)
flag (these values may be added (ex: 4+1=centered integer gadget))
0=left justified text
1=center justified text
2=right justified text
4=integer gadget (only numeric input allowed)
buffer$=default text plus enough space to bring it up to the length
given in length. For instance: buffer$="default"+STRING$(34,0)
would be sufficient for a maximum length of 41 (actual text length
would be 40).
RETURN VALUES:
buffer$ will contain the string which the user typed terminated with a
NULL$ and followed by who-knows-what up to the maximum length. You
could remove the garbage with a command such as:
msg$=LEFT$(buffer$,INSTR(buffer$,nl$)-1)
If you were going to use this to feed something such as a bopenr&
command or a shadow& command where you need a NULL terminated
string, you could leave off the `-1' in the previous command and the
string would still be NULL terminated!
jlib& will also contain the input value is an integer gadget was
selected.
shadow& x,y,SADD(msg$)
DESCRIPTION:
The same as printat& except that text is printed with a dropshadow,
and the colors are specified with the scolr& command and shadow
position is specified with the sxy& command. An additional feature is
that if a -1 x value is given, the text will be printed centered in
the window's current drawing area (this will look slightly off-center
to the left if the window has a sizing gadget). -2 will right-justify
the text.
INPUT VALUES:
x=the x position (-1 to center-justify, or -2 to right-justify)
y=the y position
msg$=the text you wish printed
RETURN VALUES:
none
style& style
DESCRIPTION:
Changes the printing style of the current font.
INPUT VALUES:
style (may be added together to combine styles)
0=normal
1=underline
2=bold
4=italics
RETURN VALUES:
none
sxy& x,y
DESCRIPTION:
Sets shadow position for the shadow& command.
INPUT VALUES:
x=shadow x-offset
y=shadow y-offset
RETURN VALUES:
none
text& SADD(msg$)
DESCRIPTION:
Prints the specified text using the system Text& routine. This is
much faster than BASIC's PRINT function and also work with italics
(while PRINT chops the letters).
INPUT VALUES:
msg$=the text you wish printed
RETURN VALUES:
none
title& SADD(title$)
DESCRIPTION:
Changes the text in a window's title bar.
INPUT VALUES:
title$=the new text for the title bar
RETURN VALUES:
none
usefont& handle
DESCRIPTION:
Changes the current font.
INPUT VALUES:
handle=a font handle obtained with loadfont& - even the default TOPAZ
font must be opened if you wish to return to it after another font
RETURN VALUES:
none
w7& WINDOW(7)
DESCRIPTION:
Passes pointer to window struvture to jlib. jlib MUST have a valid
value here before calling any graphics-related commands or a GURU is
imminent.
INPUT VALUES:
WINDOW(7)
RETURN VALUES:
none
zip& address,number,value
DESCRIPTION:
Fills a memory block with a given word-sized value.
INPUT VALUES:
address=the starting address of the memory block
number=the number of words to write
value=the value you wish written
RETURN VALUES:
none